﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Maticsoft.DBUtility;//请先添加引用

namespace BaoJian.Control
{
    enum ColType
    {
       News,Images
    }
    /// <summary>
    /// Col.aspx中的栏目news
    /// </summary>
    public partial class colnews : System.Web.UI.UserControl
    {
        public string ColumnID;
        public string ColumnName;
        public int Count = 10;
        public int TitleLengh = 10;
        public string Region = "beijing";
        public string DivClass = "title200";
        public string TitleClass = "ico2";
        public bool AutoGetColumnName = true;
        //public int RepeatColumns = 1;
        //public string LiClass = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ColumnID == null || ColumnID == string.Empty)
                return;
            //if (!Page.IsPostBack)
            //{
                BindData();
            //}
        }
        void BindData()
        {           
            if (AutoGetColumnName)
            {   LYQ.BLL.SysObj sysBll = new LYQ.BLL.SysObj();
                LYQ.Model.SysObj sysModel = sysBll.GetModel(ColumnID);
                ColumnName = sysModel.OName;
            }

            try
            {
                string sql = " SELECT top {0} oid,left(title,{1}) as Title FROM doc where  region = '{2}' and PID='{3}' and publish=1 order by sid desc ";
                sql = string.Format(sql, Count,TitleLengh, Region, ColumnID);
                DataSet ds = DbHelperSQL.Query(sql);   
                Repeater1.DataSource = ds.Tables[0];
                Repeater1.DataBind();
            }
            catch
            {
                Page.Response.Redirect("error.aspx");
            }            
        }
    }
}